function t(t) {
    var e = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : "/";
    return [ t.getFullYear(), t.getMonth() + 1, t.getDate() ].map(n).join(e);
}

function e(t) {
    var e = new Date();
    return t = new Date(t), e.setHours(0, 0, 0, 0) === t.setHours(0, 0, 0, 0);
}

function r(t) {
    var e = new Date(), r = new Date(e.getTime() - g);
    return t = new Date(t), r.setHours(0, 0, 0, 0) === t.setHours(0, 0, 0, 0);
}

function n(t) {
    return (t = t.toString())[1] ? t : "0" + t;
}

function u(t) {
    if (void 0 === t) return 0;
    var e = t.match(/[^\x00-\x80]/g);
    return t.length + (e ? e.length : 0);
}

function o(t, e) {
    return /^https?:\/\/img.ibos.cn/.test(t) ? t + "@" + e : t;
}

function i(t, e) {
    return o(t, e);
}

function a(t, e, r) {
    var n = {};
    return t.forEach(function(t) {
        var u = t[e];
        r && r(u, t), n[u] = n[u] || [], n[u].push(t);
    }), {
        groupedList: n,
        groupedKeys: Object.keys(n).sort()
    };
}

function c() {
    var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : "", e = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : "", r = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : "确定";
    return wx.showModal({
        title: e,
        content: t,
        confirmText: r,
        showCancel: !1
    });
}

function s(t) {
    var e = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : "avatar", r = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : 100;
    return t[e + "Thumb"] = i(t[e], r + "h_" + r + "w_1e_1c"), t;
}

function f(t) {
    var e = (t += "").lastIndexOf(".");
    return -1 !== e ? t.slice(e + 1) : "";
}

Object.defineProperty(exports, "__esModule", {
    value: !0
});

var l = function() {
    function t(t, e) {
        var r = [], n = !0, u = !1, o = void 0;
        try {
            for (var i, a = t[Symbol.iterator](); !(n = (i = a.next()).done) && (r.push(i.value), 
            !e || r.length !== e); n = !0) ;
        } catch (t) {
            u = !0, o = t;
        } finally {
            try {
                !n && a.return && a.return();
            } finally {
                if (u) throw o;
            }
        }
        return r;
    }
    return function(e, r) {
        if (Array.isArray(e)) return e;
        if (Symbol.iterator in Object(e)) return t(e, r);
        throw new TypeError("Invalid attempt to destructure non-iterable instance");
    };
}(), d = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(t) {
    return typeof t;
} : function(t) {
    return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
}, g = 864e5, p = function(t) {
    var e = void 0 === t ? "undefined" : d(t);
    return "function" === e || "object" === e && !!t;
}, v = function(t) {
    if (!p(t)) return [];
    var e = [];
    for (var r in t) e.push(r);
    return e;
}, h = function(t, e) {
    return function(r) {
        var n = arguments.length;
        if (n < 2 || null == r) return r;
        for (var u = 1; u < n; u++) for (var o = arguments[u], i = t(o), a = i.length, c = 0; c < a; c++) {
            var s = i[c];
            e && void 0 !== r[s] || (r[s] = o[s]);
        }
        return r;
    };
}(v);

exports.default = {
    isEmptyObject: function(t) {
        return !Object.keys(t).length;
    },
    extend: h,
    formatNumber: n,
    formatDate: t,
    formatTime: function(e) {
        var r = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : "/", u = e.getHours(), o = e.getMinutes(), i = e.getSeconds();
        return t(e, r) + " " + [ u, o, i ].map(n).join(":");
    },
    formatLocalDate: function(t) {
        var e = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : "Y年M月D日 h:m:s", r = new Date(1e3 * t), u = {
            Y: r.getFullYear(),
            M: n(r.getMonth() + 1),
            D: n(r.getDate()),
            h: n(r.getHours()),
            m: n(r.getMinutes()),
            s: n(r.getSeconds())
        };
        return e.replace(/Y|M|D|h|m|s/g, function(t) {
            return u[t];
        });
    },
    formatDecimal: function() {
        var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : "";
        return t = "" + t, t = t.replace(/^\./g, "0."), (t = t.replace(/\.{2,}/g, ".")).replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
    },
    humanizeTime: function(u) {
        var o = [ (u = new Date(u)).getHours(), u.getMinutes() ].map(n).join(":");
        return e(u) ? "今天" + o : r(u) ? "昨天" + o : t(u);
    },
    isVerifyCode: function(t) {
        return /^\d{4}$/.test(t);
    },
    isToday: e,
    isYesterday: r,
    isMobile: function(t) {
        return /^1\d{10}$/.test(t);
    },
    isEmail: function(t) {
        return /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/.test(t);
    },
    isChn: function(t) {
        return /^[\u4E00-\u9FA5]+$/.test(t);
    },
    isNum: function(t) {
        return /^[0-9-]*$/.test(t);
    },
    isTel: function(t) {
        return /^(\(\d{3,4}\)|\d{3,4}-|\s)?\d{7,14}$/.test(t);
    },
    isPrice: function(t) {
        return /(^[1-9](\d+)?(\.\d{1,2})?$)|(^(0){1}$)|(^\d\.\d{1,2}?$)/.test(t);
    },
    isPositiveInt: function(t) {
        return /^[1-9][0-9]*$/.test(t);
    },
    chunk: function(t) {
        var e = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 3;
        if (!t || !t.length) return [];
        for (var r = [], n = 0; n <= t.length; n += e) r.push(t.slice(n, n + e));
        return r;
    },
    clearBOMAndParseJson: function(t) {
        if ("string" == typeof t) try {
            return JSON.parse(t.trim());
        } catch (t) {
            return {};
        }
        return t;
    },
    formatMobile: function(t) {
        var e = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : "-";
        return "" + t.slice(0, 3) + e + t.slice(3, 7) + e + t.slice(7);
    },
    formatInputMobile: function(t) {
        var e = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : " ", r = t.length, n = [ t.slice(0, 3) ];
        return r > 3 && n.push(t.slice(3, 7)), r > 7 && n.push(t.slice(7)), n.join(e);
    },
    ucFirst: function(t) {
        return "string" == typeof t ? t.slice(0, 1).toUpperCase() + t.slice(1) : t;
    },
    serializeParams: function(t) {
        var e = "";
        for (var r in t) t.hasOwnProperty(r) && (e += (e ? "&" : "") + r + "=" + t[r]);
        return e;
    },
    clipImage: o,
    getAvatar: i,
    groupByKey: a,
    groupByLetterKey: function(t, e, r) {
        return a(t, e, r);
    },
    groupByTimestampDesc: function(n, u) {
        var o = [], i = {}, a = h([], n);
        return a.sort(function(t, e) {
            return t[u] < e[u] ? 1 : -1;
        }), a.forEach(function(n) {
            var a = new Date(1e3 * n[u]), c = void 0;
            c = e(a) ? "今天" : r(a) ? "昨天" : t(a, "-"), i[c] || (i[c] = [], o.push(c)), i[c].push(n);
        }), {
            groupedKeys: o,
            groupedList: i
        };
    },
    isObject: p,
    allKeys: v,
    qAlert: c,
    requestFailTip: function(t, e) {
        var r = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : "网络不稳定，请尝试下拉页面刷新";
        console.log("request error", t);
        var n = [ "request:fail:interrupted", "request:fail interrupted", "request:fail createRequestTask:fail:interrupted" ];
        t && -1 !== n.indexOf(t.errMsg) ? console.log("由小程序退出而引起的网络中退") : c(r, e);
    },
    convertNumber: function(t) {
        return null === t || void 0 === t ? 0 : (t = t.toString()).length >= 5 ? t.slice(0, -3) + "k+" : t;
    },
    filterEmoji: function(t) {
        var e = new RegExp("(?:[✀-➿]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff]|[#-9]️?⃣|㊙|㊗|〽|〰|Ⓜ|\ud83c[\udd70-\udd71]|\ud83c[\udd7e-\udd7f]|🆎|\ud83c[\udd91-\udd9a]|\ud83c[\udde6-\uddff]|[\ud83c[\ude01-\ude02]|🈚|🈯|[\ud83c[\ude32-\ude3a]|[\ud83c[\ude50-\ude51]|‼|⁉|[▪-▫]|▶|◀|[◻-◾]|©|®|™|ℹ|🀄|[☀-⛿]|⬅|⬆|⬇|⬛|⬜|⭐|⭕|⌚|⌛|⌨|⏏|[⏩-⏳]|[⏸-⏺]|🃏|⤴|⤵|[←-⇿])", "g");
        return t.replace(e, "");
    },
    getByteLength: u,
    sliceByByte: function(t, e) {
        for (var r = "", n = 0, o = 0, i = t.length; o < i && !(n / 2 >= e); o++) n = u(r += t[o]);
        return r;
    },
    formatTimeStamp: function(e) {
        for (var r = Math.ceil((new Date().getTime() - 1e3 * e) / 1e3), n = [ "86400", "3600", "60", "1" ], u = {
            86400: "天",
            3600: "小时",
            60: "分钟",
            1: "秒"
        }, o = 0; o < n.length; o++) {
            var i = n[o], a = Math.floor(r / Number(i));
            if (0 !== a) return "86400" === i ? 1 === a ? "昨天" : t(new Date(1e3 * e), "-") : a + u[i] + "前";
        }
    },
    successTip: function(t, e) {
        wx.showToast({
            title: t + "成功",
            duration: 500,
            success: e
        });
    },
    showTips: function(t) {
        wx.showModal(Object.assign({}, t, {
            success: function(e) {
                e.confirm && t.success && t.success();
            }
        }));
    },
    addThumbToData: s,
    addThumbToList: function(t) {
        var e = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : "avatar", r = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : 100;
        return t.forEach(function(t) {
            t = s(t, e, r);
        }), t;
    },
    parseUrl: function() {
        var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : "", e = {}, r = (t = t.substr("/" === t.charAt(0) ? 1 : 0)).split("?"), n = l(r, 2), u = n[0], o = n[1];
        return o && o.split("&").forEach(function(t) {
            var r = t.split("="), n = l(r, 2), u = n[0], o = n[1];
            e[u] = o;
        }), {
            url: u,
            query: e
        };
    },
    sliceStr: function() {
        var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : "", e = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 10, r = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : "...";
        return t.length > e ? t.slice(0, e) + r : t;
    },
    getExtname: f,
    getFileType: function(t) {
        var e = "";
        return t = f(t), /pdf/.test(t) ? e = "pdf" : /doc|docx/.test(t) ? e = "doc" : /ppt|pps|pptx/.test(t) ? e = "ppt" : /xls|xlsx|xlsm|xlt|xltx|xltm/.test(t) && (e = "xls"), 
        e;
    },
    getFileSize: function(t) {
        var e = [ "Byte", "K", "M", "G" ], r = 0;
        for (t = Math.max(parseInt(t, 10) || 0, 0); t >= 1024 && r < e.length - 1; ) t /= 1024, 
        r++;
        return +t.toFixed(1) + e[r];
    },
    transformCamel: function(t) {
        var e = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : "-", r = new RegExp(e + "(\\w)", "g");
        return t.replace(r, function(t, e) {
            return e.toUpperCase();
        });
    },
    parseLaunchQueryString: function(t) {
        if ("object" === (void 0 === t ? "undefined" : d(t))) return t;
        if ("string" == typeof t) {
            var e = {};
            return (t = t.replace(/[{}]/g, "")).split(",").forEach(function(t) {
                var r = t.split("="), n = l(r, 2), u = n[0], o = n[1];
                e[u] = o;
            }), e;
        }
        return {};
    }
};